package com.toolbox.util;

import com.toolbox.enums.CacheEnum;
import com.toolbox.enums.ClientEnum;
import com.toolbox.enums.ModuleEnum;
import org.springframework.stereotype.Component;

/**
 * <p>
 * Description：Token Key 生成模板，根据用户的类型而生成
 * </p>
 *
 * @author Mango
 * @version v1.0.0
 * @date 2023-11-18 11:01
 * @see com.toolbox.util
 */
@SuppressWarnings("ALL")
@Component
public class KeyTemplateExt {

    /**
     * 生成key
     *
     * @param cacheEnum  缓存枚举
     * @param clientEnum 客户端枚举
     * @param moduleEnum 模块枚举
     * @param userType   用户类型
     * @return key {@link String}
     */
    public String generatedCacheKey(CacheEnum cacheEnum, ClientEnum clientEnum, ModuleEnum moduleEnum, Integer userType) {
        StringBuilder sb = new StringBuilder();

        sb.append("validate:")
                .append(cacheEnum.getIndex()).append(":")
                .append(clientEnum.getIndex()).append(":")
                .append(moduleEnum.getIndex()).append(":")
                .append(userType);

        return sb.toString();
    }

}
